# In make files we always define a rule in the following form:
# <output file>: <dependencies>
# TAB <command for producing output file from dependencies>

# In makefiles we have to use tabs for indentation. Otherwise we will get the
# error: "Makefile:...: *** missing separator.  Stop."

CC=gcc
CFLAGS=-I.
DEPS = hellomake.h
OBJ = hellomake.o hellofunc.o

# all object files depend on their .c files and all depend on DEPS
# $@ says to put the output of the compilation result to the file named on the left side of the ":"
# $< is the first item in the dependencies list
%.o: %.c $(DEPS)
	$(CC) -c -o $@ $< $(CFLAGS)

# hellomake consists of the object files, which according to the first rules
# depend on their corresponding .c files
# $@: the left hand side of the colon
# $^: the right hand side of the colon
hellomake: $(OBJ)
	$(CC) -o $@ $^ $(CFLAGS)
